/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.cmu.mism.dgjava.data.models.option.impl;

import edu.cmu.mism.dgjava.data.models.option.BaseType;
import edu.cmu.mism.dgjava.data.models.option.OptionModelPackage;
import edu.cmu.mism.dgjava.data.models.option.PricingModel;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Pricing Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.PricingModelImpl#getType <em>Type</em>}</li>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.PricingModelImpl#isImplyVolatility <em>Imply Volatility</em>}</li>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.PricingModelImpl#getExercisePrice <em>Exercise Price</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PricingModelImpl extends EObjectImpl implements PricingModel {
	/**
	 * The default value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected static final BaseType TYPE_EDEFAULT = BaseType.PUT;

	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected BaseType type = TYPE_EDEFAULT;

	/**
	 * The default value of the '{@link #isImplyVolatility() <em>Imply Volatility</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isImplyVolatility()
	 * @generated
	 * @ordered
	 */
	protected static final boolean IMPLY_VOLATILITY_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isImplyVolatility() <em>Imply Volatility</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isImplyVolatility()
	 * @generated
	 * @ordered
	 */
	protected boolean implyVolatility = IMPLY_VOLATILITY_EDEFAULT;

	/**
	 * The default value of the '{@link #getExercisePrice() <em>Exercise Price</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExercisePrice()
	 * @generated
	 * @ordered
	 */
	protected static final double EXERCISE_PRICE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getExercisePrice() <em>Exercise Price</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExercisePrice()
	 * @generated
	 * @ordered
	 */
	protected double exercisePrice = EXERCISE_PRICE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PricingModelImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OptionModelPackage.Literals.PRICING_MODEL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BaseType getType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(BaseType newType) {
		BaseType oldType = type;
		type = newType == null ? TYPE_EDEFAULT : newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.PRICING_MODEL__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isImplyVolatility() {
		return implyVolatility;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setImplyVolatility(boolean newImplyVolatility) {
		boolean oldImplyVolatility = implyVolatility;
		implyVolatility = newImplyVolatility;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.PRICING_MODEL__IMPLY_VOLATILITY, oldImplyVolatility, implyVolatility));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getExercisePrice() {
		return exercisePrice;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setExercisePrice(double newExercisePrice) {
		double oldExercisePrice = exercisePrice;
		exercisePrice = newExercisePrice;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.PRICING_MODEL__EXERCISE_PRICE, oldExercisePrice, exercisePrice));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OptionModelPackage.PRICING_MODEL__TYPE:
				return getType();
			case OptionModelPackage.PRICING_MODEL__IMPLY_VOLATILITY:
				return isImplyVolatility();
			case OptionModelPackage.PRICING_MODEL__EXERCISE_PRICE:
				return getExercisePrice();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OptionModelPackage.PRICING_MODEL__TYPE:
				setType((BaseType)newValue);
				return;
			case OptionModelPackage.PRICING_MODEL__IMPLY_VOLATILITY:
				setImplyVolatility((Boolean)newValue);
				return;
			case OptionModelPackage.PRICING_MODEL__EXERCISE_PRICE:
				setExercisePrice((Double)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OptionModelPackage.PRICING_MODEL__TYPE:
				setType(TYPE_EDEFAULT);
				return;
			case OptionModelPackage.PRICING_MODEL__IMPLY_VOLATILITY:
				setImplyVolatility(IMPLY_VOLATILITY_EDEFAULT);
				return;
			case OptionModelPackage.PRICING_MODEL__EXERCISE_PRICE:
				setExercisePrice(EXERCISE_PRICE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OptionModelPackage.PRICING_MODEL__TYPE:
				return type != TYPE_EDEFAULT;
			case OptionModelPackage.PRICING_MODEL__IMPLY_VOLATILITY:
				return implyVolatility != IMPLY_VOLATILITY_EDEFAULT;
			case OptionModelPackage.PRICING_MODEL__EXERCISE_PRICE:
				return exercisePrice != EXERCISE_PRICE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (type: ");
		result.append(type);
		result.append(", implyVolatility: ");
		result.append(implyVolatility);
		result.append(", exercisePrice: ");
		result.append(exercisePrice);
		result.append(')');
		return result.toString();
	}

	/**
	 * @generated NOT
	 */
	@Override
	public Object clone() {
		try {
			return super.clone();
		} catch (CloneNotSupportedException e) {
			return null;
		}
	}

} //PricingModelImpl
